package com.guigu.community.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.guigu.community.mapper.CarouselMapper;
import com.guigu.community.pojo.Carousel;
import com.guigu.community.service.CarouselService;
import com.guigu.community.vo.CarouselVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

import static com.sun.jmx.snmp.EnumRowStatus.active;

@Service
public class CarouselServiceImpl extends ServiceImpl<CarouselMapper, Carousel> implements CarouselService {
    @Autowired
    private CarouselMapper carouselMapper;
    @Override
    public PageInfo<Carousel> queryVo(Integer pageNo, Integer pageSize, CarouselVo vo) {
        PageHelper.startPage(pageNo, pageSize);
        List<Carousel> carousels = carouselMapper.selectCarousel(vo);
        PageInfo<Carousel> carouselPageInfo = new PageInfo<>(carousels);
        return carouselPageInfo;
    }

    @Override
    public List<Carousel> queryCarousel(CarouselVo vo) {
        return carouselMapper.selectCarousel(vo);
    }

    @Override
    public Boolean modifCarouselActive(Integer cid, Integer active) {
        Integer integer = carouselMapper.updateIsActive(cid, active);
        return integer >0;
    }

}
